import { defineStore } from 'pinia'
import {useTagsStore} from '@/store/tags'
import {userLoginStore} from '@/store/userLogin'

export const useLogoutStore = defineStore('logout', () => {
  const tagsStore = useTagsStore()
  const userLogin = userLoginStore()
  const cleanStore = () => {
    tagsStore.tags = [
      {
        path: '/home',
        name: 'home',
        label: '首页',
        icon: 'home'
      }
    ]
    userLogin.routerList.forEach(item => {
      // 路由移除
      if (item) item()
    })
    userLogin.menuList = []
    userLogin.token = ''
  }

  return {
    cleanStore
  }
})